package cn.gemiman.daoyi.framework.common.enums;

import cn.gemiman.daoyi.framework.common.core.IntArrayValuable;
import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 全局站点足迹类型枚举
 */
@AllArgsConstructor
@Getter
public enum FootprintForTypeEnum implements IntArrayValuable {

    SITE(0, "站点"),
    ARTICLE(1, "文章"),
    COMMENT(2, "评论"),
    TALK(3, "说说"),
    MESSAGE(4, "留言");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(FootprintForTypeEnum::getValue).toArray();

    /**
     * 类型
     */
    private final Integer value;
    /**
     * 类型名
     */
    private final String name;

    public static FootprintForTypeEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), FootprintForTypeEnum.values());
    }

    @Override
    public int[] array() {
        return ARRAYS;
    }
}
